package cn;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Ran {
	int[] input() {
		Random r = new Random();
		System.out.println("随机产生一数组：");

		int[] arr = new int[5];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = r.nextInt(100) + 1;
			for (int j = 0; j < i; j++) {
				if (arr[i] == arr[j])
					i--;
			}
		}
		System.out.println(Arrays.toString(arr));
		return arr;
	}

	int[] selectSort(int[] arr) {
		// 轮数
		for (int i = 0; i < arr.length - 1; i++) {
			//
			for (int j = i+1; j < arr.length ; j++) {
				if (arr[i] < arr[j]) {
					int temp = arr[j];
					arr[j] = arr[i];
					arr[i] = temp;
				}
			}

		}
		return arr;
	}

	void outPut(int[] arr) {
		System.out.println("请输出排序后的数组：");

		System.out.println(Arrays.toString(arr));

	}

	public static void main(String[] args) {
		Ran r = new Ran();
		int[] arr = r.input();
		int[] newArr = r.selectSort(arr);
		r.outPut(newArr);
	}

}
